package com.source.multithread.randomaccess;

import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

/**
 * @Author wengqy
 * @Date 2020/12/26
 */
public class RandomAccessFileDemo {
    public static void main(String[] args) throws Exception {
        String s="                                                                                                    ";
   //     System.out.println(s.length());
        RandomAccessFile random  = new RandomAccessFile("a.txt","rw");
        random.seek(100);
        FileChannel channel = random.getChannel();
        long filePointer = random.getFilePointer();
        System.out.println(filePointer);
        random.write("weng2".getBytes());
        random.seek(filePointer+"weng2".length());
        random.write("quan".getBytes());
        random.write("yaun".getBytes());

        long filePointer1 = random.getFilePointer();
        System.out.println(filePointer1);
        random.close();
    }
}
